package org.codeart.api_driver.service;

import org.codeart.api_driver.remote.ServiceOrderClient;
import org.codeart.common.constant.IdentityEnum;
import org.codeart.common.dto.OrderInfo;
import org.codeart.common.request.OrderRequest;
import org.codeart.common.util.HttpStatus;
import org.codeart.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderApiService {

    @Autowired
    private ServiceOrderClient serviceOrderClient;

    public boolean toPickUpPassenger(OrderRequest orderRequest) {
        R<Void> r = serviceOrderClient.toPickUpPassenger(orderRequest);
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public boolean arriveDeparture(OrderRequest orderRequest) {
        R<Void> r = serviceOrderClient.arriveDeparture(orderRequest);
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public boolean pickUpPassenger(OrderRequest orderRequest) {
        R<Void> r = serviceOrderClient.pickUpPassenger(orderRequest);
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public boolean passengerGetOff(OrderRequest orderRequest) {
        R<Void> r = serviceOrderClient.passengerGetOff(orderRequest);
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public boolean cancel(Long orderId) {
        R<Void> r = serviceOrderClient.cancel(orderId, IdentityEnum.DRIVER.value());
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public R<OrderInfo> detail(Long orderId) {
        return serviceOrderClient.detail(orderId);
    }

    /**
     * 获取当前订单信息
     * @param phone 手机
     * @param identity  身份
     */
    public R<OrderInfo> currentOrder(String phone, String identity) {
        return serviceOrderClient.current(phone,identity);
    }
}
